package com.forum.module.chat.convert.chat;

import com.forum.framework.common.util.colletion.CollectionUtils;
import com.forum.framework.common.util.object.BeanUtils;
import com.forum.module.chat.controller.vo.ChatMessageRespVO;
import com.forum.module.chat.dal.dataobject.chat.ChatMessageDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface ChatMessageConvert {
    ChatMessageConvert INSTANCE = Mappers.getMapper(ChatMessageConvert.class);

    default List<ChatMessageRespVO> covertList(List<ChatMessageDO> list) {
        return CollectionUtils.convertList(list, this::covert);
    }

    default ChatMessageRespVO covert(ChatMessageDO chatMessageDO) {
        return BeanUtils.toBean(chatMessageDO, ChatMessageRespVO.class);
    }
}
